package com.lg.partition31;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/6/4 9:40
 */
public class P3052USACO12MAR_CowsInASkyscraperG {

    private static final int N = 20;
    //f[i]表示在进入电梯情况是i时需要的最少次数，g[i]表示状态是i时剩余的可用空间
    private static int[] w = new int[N], f = new int[1 << N], g = new int[1 << N];
    private static int n, m;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); m = nextInt();
        for (int i = 0; i < n; i++) w[i] = nextInt();
        for (int i = 0; i < 1 << N; i++) f[i] = 110;
        f[0] = 1;
        g[0] = m;
        for (int s = 0; s < 1 << n; s++) {
            for (int i = 0; i < n; i++) {
                if ((s >> i & 1) == 1) continue;
                if (g[s] >= w[i] && f[s | 1 << i] >= f[s]) {
                    g[s | 1 << i] = Math.max(g[s | 1 << i], g[s] - w[i]);
                    f[s | 1 << i] = f[s];
                } else if (g[s] < w[i] && f[s | 1 << i] >= f[s] + 1) {
                    g[s | 1 << i] = Math.max(g[s | 1 << i], m - w[i]);
                    f[s | 1 << i] = f[s] + 1;
                }
            }
        }
        writer.println(f[(1 << n) - 1]);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
